/*
 * Copyright @ 苏州瑞云信息技术有限公司 All rights reserved.
 */
package cn.com.recloud.bbs.controller;

import cn.com.recloud.bbs.entity.bbs_article;
import cn.com.recloud.bbs.service.SearchArticleService;
import cn.com.recloud.bbs.vo.AppListArticVO;
import cn.com.recloud.core.util.Result;
import cn.com.recloud.one.spring.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: app端活动、文章搜索
 * @author: wayne Wang
 * @date: 2020-6-23
 */
@Api("搜索任务")
@RestController
@RequestMapping("/api/bbs/search")
public class SearchController extends BaseController<bbs_article,SearchArticleService> {

    @Autowired
    SearchArticleService searchArticleService;

    @GetMapping("/findTopTen")
    @ApiOperation("查询最新前十的推荐文章")
    public Result findTopTen(){
        List<bbs_article> topTen = searchArticleService.findTopTen();
        return new Result(topTen);
    }

    @GetMapping("/searchAllArticle")
    @ApiOperation(value = "搜索发布文章，不分类别")
    public Result listAppCampaign(String name,
                                  @RequestParam(required = false,defaultValue = "1")Integer pageIndex,
                                  @RequestParam(required = false,defaultValue = "15")Integer pageSize){
        List<AppListArticVO> list = searchArticleService.findAllArticle(name,pageIndex,pageSize);
        return new Result(list);
    }
}
